package com.business_clean.ui.adapter.depart;

import android.text.TextUtils;
import android.widget.TextView;

import androidx.core.content.ContextCompat;

import com.business_clean.R;
import com.business_clean.app.weight.CustomAvatarView;
import com.business_clean.data.mode.roster.RosterEntity;
import com.business_clean.data.mode.roster.RosterList;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import org.jetbrains.annotations.NotNull;

public class DepartAdapter extends BaseQuickAdapter<RosterList, BaseViewHolder> {
    public DepartAdapter() {
        super(R.layout.item_depart);
        addChildClickViewIds(R.id.iv_item_roster_call);
    }

    @Override
    protected void convert(@NotNull BaseViewHolder holder, RosterList item) {
        holder.setText(R.id.tv_item_roster_name, item.getUser_name());

        CustomAvatarView avatarView = holder.getView(R.id.iv_item_roster_avatar);
        avatarView.setAvatar(item.getAvatar(), item.getUser_name());
        avatarView.getAvatarText().setTextSize(16f);

        //在这里呀哦区分身份 如果是保洁员，那么就显示基本信息
        StringBuilder stringBuilder = new StringBuilder();
        if (!TextUtils.isEmpty(item.getSex_name())) {
            stringBuilder.append(item.getSex_name());
        }
        if (!TextUtils.isEmpty(item.getJob_name())) {
            stringBuilder.append(" / ").append(item.getJob_name());
        }
        if (!TextUtils.isEmpty(item.getAge())) {
            stringBuilder.append(" / ").append(item.getAge()).append("岁");
        }
        if (!TextUtils.isEmpty(item.getWork_age())) {
            stringBuilder.append(" / ").append(item.getWork_age() + "").append("年");
        }
        holder.setText(R.id.tv_item_roster_desc, stringBuilder.toString());



    }
}
